#ifndef Log_h
#define Log_h

#include "Error.h"
#include "Session.h"
#include "Request.h"


class Log_T
{
private:
	char _szFilename[MAX_PATH];
	SYSTEMTIME _date;
	File_T * _filePtr;
	CriticalSection_T _cs;
	Timer_T _timer;

public:
	Log_T(const char * szFilename);
	~Log_T();

public:
	void Write(const char * sz);
	void Write(const Session_T & session, Request_T & request, const char * szRulesName, const Error_T & err);

private:
	void Open();
	void WriteDate();
	void WriteError(const Error_T & err);
	void WriteSession(const Session_T & session);
	void WriteRequest(Request_T & request);

public:
	static List_T<Log_T> * s_logListPtr;
	static void Load();
	static void Unload();
	static Log_T * Load(const char * szFilename);
};

#endif //Log_h